﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BASE;

public partial class Admin_xemthoikhoabieu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //check quyen vao trang

        if (Utils.getIntSession("userid") == 0)
        {
            Response.Redirect("/admin/login.aspx");
        }
        Session["trang"] = Constants.ADMINTHOIKHOABIEU;
        if (!IsPostBack)
        {
            bintuan();
        }
    }
    protected void btn_luu_Click(object sender, EventArgs e)
    {
        binlichhoc(int.Parse(dr_tuan.SelectedValue), txt_lop.Text);
    }
    void bintuan()
    {
        busTuan busT = new busTuan();
        dr_tuan.DataSource = busT.getAllTuan2();
        dr_tuan.DataTextField = "Ten";
        dr_tuan.DataValueField = "Tuan";
        dr_tuan.DataBind();
        ListItem lstitem = new ListItem();
        lstitem = dr_tuan.Items.FindByValue(getTuanHienTai().ToString());
        if (lstitem != null)
        {
            lstitem.Selected = true;
        }
    }
    int getTuanHienTai()
    {
        busTuan busT = new busTuan();
        return busT.getTuanHienTai();
    }
    void binlichhoc(int tuan, string lop)
    {
        busThoiKhoaBieu busTK = new busThoiKhoaBieu();
        List<entThoiKhoaBieu> lst = new List<entThoiKhoaBieu>();
        lst = busTK.getByTuan(tuan, lop);
        if (lst.Count == 0)
        {
            lb_me.Text = "Chưa có lịch";
            gr_tkb.Visible = false;
            return;
        }
        else
        {
            lb_me.Text = "";
            gr_tkb.Visible = true;
        }
        gr_tkb.DataSource = lst;
        gr_tkb.DataBind();
    }
}